const express = require("express");
const bodyParser = require("body-parser");
const app = express();
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended:true}));
//get请求query参数
app.get("/test",(req,res)=>{
    console.log(req.query);
    res.send("测试get请求query参数");
})
//get请求params参数
app.get("/testparams/:name/:age",(req,res)=>{
    console.log(req.params);
    res.send("测试get请求params参数");
})
//post请求
app.post("/testpost",(req,res)=>{
    console.log(req.body);
    res.send("post请求");
})
app.listen(3000,err=>{
    if(!err) console.log("服务器启动成功！");
    else console.log(err);
})